package com.zz.ecommerce.user;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.Map;

/**
 * 用户dao
 *
 * @author
 */
@Repository
public interface UserDao {

    @Select("SELECT * FROM org_user WHERE ISDELETE = 'N' AND LOGNAME=#{userId} AND LOGPASSWORD=#{passwd}")
    UserInfo getUserById(@Param("userId") String userId, @Param("passwd") String passwd);


    @Update("update org_user set LOGPASSWORD=#{newPasswd} where LOGNAME=#{userId} AND LOGPASSWORD=#{oldPasswd}")
    boolean updatePasswd(@Param("userId") String userId, @Param("oldPasswd") String oldPasswd,
                         @Param("newPasswd") String newPasswd);

    @Select("select auth.sys_enterprise_info.distinct_sign\n" +
            "  from auth.sys_user,\n" +
            "       auth.sys_user_organization_job,\n" +
            "       auth.sys_organization,\n" +
            "       auth.sys_enterprise_info\n" +
            " where auth.sys_user.username = #{userName}\n" +
            "   and auth.sys_user.id = auth.sys_user_organization_job.user_id\n" +
            "   and auth.sys_organization.id =\n" +
            "       auth.sys_user_organization_job.organization_id\n" +
            "   and auth.sys_enterprise_info.organization_id =\n" +
            "       auth.sys_organization.organization_code AND ROWNUM=1")
    Map getDistinctSign(@Param("userName") String useName);
}
